(setq *eus-cgal-dir* (format nil "~A" (read-line (piped-fork "rospack find eus_CGAL"))))
(load (format nil "~A/euslisp/eus-xyz-off.l" *eus-cgal-dir*))

(defun make-trimesh-ordered-points (3dp &key (reverse nil) (return-faceset nil))
  (let ((input-file-name (format nil "3dp-~A.xyz" (send 3dp :name)))
        (output-file-name (format nil "3dp-~A.off" (send 3dp :name)))
        ret-3dp trimesh)
    (3dp->xyz 3dp input-file-name :scale 0.001)
    (piped-fork
     (format nil
             "~A/examples/Surface_reconstruction_points_3/poisson_reconstruction ~A ~A" *eus-cgal-dir* input-file-name output-file-name))
    (unix:usleep (* 30 1000 1000))
    (setq trimesh (off2eus output-file-name :scale 1000.0 :reverse reverse))
    (setq ret-3dp (instance 3dpointcloud :init :points (send trimesh :vertices)))
    (if return-faceset (list ret-3dp trimesh) ret-3dp)
    ))
